package com.monlyu.action.statistics;

import java.util.List;

import com.monlyu.action.BaseAction;
import com.monlyu.bo.EnumsBo;
import com.monlyu.bo.StatisticsBo;
import com.monlyu.model.LevelScoreQueryModel;
import com.monlyu.util.StringUtil;
import com.monlyu.vo.Manuscript;

/**
 * @author SongJun
 * @since 2010-3-15
 * @description
 */
public class LevelScoreSumAction extends BaseAction {
	private StatisticsBo statisticsBo;
	private LevelScoreQueryModel lsqModel;
	private List<LevelScoreQueryModel> lsqm;
	private EnumsBo enumsBo;
	private long wglevel = 0;
	private float wgscore = 0;
	private int sytimes = 0;
	private float bjsorce = 0;

	public long getWglevel() {
		return wglevel;
	}

	public void setWglevel(long wglevel) {
		this.wglevel = wglevel;
	}

	public int getSytimes() {
		return sytimes;
	}

	public void setSytimes(int sytimes) {
		this.sytimes = sytimes;
	}

	public float getWgscore() {
		return wgscore;
	}

	public void setWgscore(float wgscore) {
		this.wgscore = wgscore;
	}

	public float getBjsorce() {
		return bjsorce;
	}

	public void setBjsorce(float bjsorce) {
		this.bjsorce = bjsorce;
	}

	public LevelScoreQueryModel getLsqModel() {
		return lsqModel;
	}

	public void setLsqModel(LevelScoreQueryModel lsqModel) {
		this.lsqModel = lsqModel;
	}

	public List<LevelScoreQueryModel> getLsqm() {
		return lsqm;
	}

	public void setStatisticsBo(StatisticsBo statisticsBo) {
		this.statisticsBo = statisticsBo;
	}

	public String toView() {
		return view("levelScoreSum.jsp");
	}

	public String toQuery() {
		lsqm = statisticsBo.getLevelScoreQuerys(lsqModel);
		for (LevelScoreQueryModel lsq : lsqm) {
			Manuscript ms = lsq.getManuscript();
			Object enumValue;
			if (ms.getPuserScore() != null) {
				enumValue = enumsBo.getEnumValue(ms.getPuserScore());
				wgscore += enumValue == null ? 0 : Float
						.parseFloat((String) enumValue);
			}
			wglevel += ms.getScore();
			sytimes += ms.getTimes();
			if (lsq.getLevel1Score() != null) {
				enumValue = enumsBo.getEnumValue(lsq.getLevel1Score());
				bjsorce += StringUtil.isEmpty(enumValue) ? 0 : Float
						.parseFloat((String) enumValue);
			}
		}
		return view("levelScoreSum.jsp");
	}

	public void setLsqm(List<LevelScoreQueryModel> lsqm) {
		this.lsqm = lsqm;
	}

	public void setEnumsBo(EnumsBo enumsBo) {
		this.enumsBo = enumsBo;
	}
}
